# Maintainer:
pkgname=opendbx
pkgver=1.4.6
pkgrel=2
pkgdesc="Database abstraction layer"
url="https://www.linuxnetworks.de/doc/index.php/OpenDBX"
arch="all"
license="GPL-2.0-or-later"
depends_dev="
	$pkgname=$pkgver-r$pkgrel
	$pkgname-backend-mysql=$pkgver-r$pkgrel
	$pkgname-backend-postgres=$pkgver-r$pkgrel
	$pkgname-backend-sqlite=$pkgver-r$pkgrel
	"
makedepends="
	libpq-dev
	mariadb-connector-c-dev
	readline-dev
	sqlite-dev
	"
subpackages="
	$pkgname-dev
	libopendbx
	libopendbxplus
	$pkgname-backend-mysql
	$pkgname-backend-postgres
	$pkgname-backend-sqlite
	"
source="https://www.linuxnetworks.de/opendbx/download/opendbx-$pkgver.tar.gz"

prepare() {
	default_prepare
	update_config_guess
	update_config_sub
}

build() {
	# ancient code
	export CXXFLAGS="$CXXFLAGS -std=c++14"

	# only checks default include for mysql.h
	export CFLAGS="$CFLAGS -I/usr/include/mysql -I/usr/include/postgresql"

	./configure \
		--prefix=/usr \
		--build=$CBUILD \
		--host=$CHOST \
		--disable-static \
		--with-backends="mysql pgsql sqlite3"
	make -j1
}

check() {
	make -j1 check
}

package() {
	make -j1 DESTDIR="$pkgdir" install
	rm -r "$pkgdir"/usr/share/man
}

libopendbx() {
	amove usr/lib/libopendbx.so.*
}

libopendbxplus() {
	amove usr/lib/libopendbxplus.so.*
}

mysql() {
	amove usr/lib/opendbx/libmysqlbackend.so*
}

postgres() {
	amove usr/lib/opendbx/libpgsqlbackend.so*
}

sqlite() {
	amove usr/lib/opendbx/libsqlite3backend.so*
}

sha512sums="
dd6d53d29157057dbf4e273fd82c7694e8bc626d3409d6ab9c25627a0fec96418326550fa8004b5341facdc4cd8aae12516224e8bb84e2562482885780ff0e55  opendbx-1.4.6.tar.gz
"
